package com.huawei;

/**
 * Created by Z-hong on 2024/7/14.
 */
import java.util.Scanner;
public class HJ24 {
    /**
     * 超时
     * @param args
     */
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int count = in.nextInt();
        int [] nums = new int[count];
        for (int i = 0; i < count; i++) {
            nums[i]=in.nextInt();
        }
        int min=count;
        for (int i = 1; i < nums.length-1; i++) {
            if(i==3){
              int j=1;
            };
            int getRight=getRight(0,nums,i+1,i);
            int getLeft=getLeft(0,nums,i-1,i);
            int getAll=getRight+getLeft;
            min = Math.min(count,getAll);

        }
        System.out.println(min);

    }
    public static int getRight(int count,int[]nums,int index,int target){
        if(index>=nums.length-1){return count;}
        if(nums[index]>=nums[target]){
            count++;
            count = Math.min(getRight(count,nums,index+1,target),getRight(count,nums,index+1,index));
        }else{
            count = getRight(count,nums,index+1,index);
        }
        return count;
    };

    public static int getLeft(int count,int[]nums,int index,int target){
        if(index<0){return count;}
        if(nums[index]>=nums[target]){
            count++;
            count = Math.min(getLeft(count,nums,index-1,target),getLeft(count,nums,index-1,index));
        }else{
            count = getLeft(count,nums,index-1,index);
        }
        return count;
    };

}
